package com.hhit.bigscreenbackmanage.controller.jsgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.PageUtil;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.entity.jsgl.*;
import com.hhit.bigscreenbackmanage.service.jsgl.JsglService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/jsglController")
public class JsglController {

    private Logger log = LoggerFactory.getLogger(JsglController.class);

    @Resource
    private JsglService jsglService;

    /**
     * 获取变电站通用设计应用率统计
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getbdztysjNum")
    public TysjBdzEntity getbdztysjNum(@RequestParam Map map) {
        try {
            return jsglService.getbdztysjNum(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取变电站通用设计应用率
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getbdztysj")
    public PageUtil<TysjBdzEntity> getbdztysj(@RequestParam Map map) {
        try {
            return jsglService.getbdztysj(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取线路通用设计
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getTysjXl")
    public PageUtil<TysjXlEntity> getTysjXl(@RequestParam Map map) {
        try {
            return jsglService.getTysjXl(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取通用设备应用
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getTysbyy")
    public PageUtil<TysjSbyylEntity> getTysbyy(@RequestParam Map map) {
        try {
            return jsglService.getTysbyy(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取新技术应用统计
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getXjsyyNum")
    public XjsyyEntity getXjsyyNum(@RequestParam Map map) {
        try {
            return jsglService.getXjsyyNum(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取新技术应用中间柱状图统计
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getXjsyyChartNum")
    public List<String> getXjsyyChartNum(@RequestParam Map map) {
        try {
            return jsglService.getXjsyyChartNum(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取新技术应用
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getXjsyy")
    public PageUtil<XjsyyEntity> getXjsyy(@RequestParam Map map) {
        try {
            return jsglService.getXjsyy(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取三维成果应用统计
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getSwcgyyNum")
    public SwccyyEntity getSwcgyyNum(@RequestParam Map map) {
        try {
            return jsglService.getSwcgyyNum(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取三维成果应用中间柱状图统计
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getSwcgyyChartNum")
    public List<String> getSwcgyyChartNum(@RequestParam Map map) {
        try {
            return jsglService.getSwcgyyChartNum(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取三维成果应用
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getSwcgyy")
    public PageUtil<SwccyyEntity> getSwcgyy(@RequestParam Map map) {
        try {
            return jsglService.getSwcgyy(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取设计质量问题统计
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getSjzlwtNum")
    public SjzlwtEntity getSjzlwtNum(@RequestParam Map map) {
        try {
            return jsglService.getSjzlwtNum(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取设计质量问题
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getSjzlwt")
    public PageUtil<SjzlwtEntity> getSjzlwt(@RequestParam Map map) {
        try {
            return jsglService.getSjzlwt(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取设计变更
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getSjbg")
    public PageUtil<SjbgEntity> getSjbg(@RequestParam Map map) {
        try {
            return jsglService.getSjbg(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取设计变更统计
     *
     * @param map
     * @return list
     */
    @RequestMapping("/getSjbgNum")
    public SjbgEntity getSjbgNum(@RequestParam Map map) {
        try {
            return jsglService.getSjbgNum(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取质量事件 统计
     * @param map
     * @return
     */
    @RequestMapping("/getSjzlwtsjCount")
    public Integer getSjzlwtsjCount(@RequestParam Map map) {
        Integer count = 0;
        try {
            count = jsglService.getSjzlwtsjCount(map);
            return count;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return count;
    }

    /**
     * 获取质量事件
     * @param map
     * @return
     */
    @RequestMapping("/getSjzlwtsj")
    public PageUtil<SjzlwtEntity> getSjzlwtsj(@RequestParam Map map) {
        PageUtil<SjzlwtEntity> page = new PageUtil<>();
        try {
            page = jsglService.getSjzlwtsj(map);
            return page;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return page;
    }


    /**
     * 查询 标准化成果应用
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getCgyyCount")
    public Response getCgyyCount(@RequestBody JSONObject jsonObject){
        try{
            Map<String, String> result = jsglService.queryCgyyCount(jsonObject);
            return Response.createResponseBySuccess("查询标准化成果应用成功",result);
        }catch (Exception e){
            log.error("查询标准化成果应用失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询标准化成果应用失败");
        }
    }
}
